package com.afei.bottomtabbar;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class RegisterActivity extends BaseActivity {
    private EditText accountEt,passwordEt,passwordAgainEt;
    private Button registerBtn;
    @Override
    public void initView() {
        contentView(R.layout.q_activiyt_register_page);
        setTitle(getResources().getString(R.string.register));
        accountEt = findViewById(R.id.account_et);
        passwordEt = findViewById(R.id.password_et);
        passwordAgainEt = findViewById(R.id.password_again_et);
        registerBtn = findViewById(R.id.register_btn);
        registerBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String account2 = accountEt.getText().toString().trim();
                if (account2.isEmpty()){
                    Toast.makeText(context,getResources().getString(R.string.input_account), Toast.LENGTH_SHORT).show();
                    return;
                }
                String password2 = passwordEt.getText().toString().trim();
                if (password2.isEmpty()){
                    Toast.makeText(context,getResources().getString(R.string.input_password), Toast.LENGTH_SHORT).show();
                    return;
                }
                String password3 = passwordAgainEt.getText().toString().trim();
                if (password2.equals(password3)){
                    Intent intent = getIntent();
                    intent.putExtra("account",account2);
                    intent.putExtra("password",password2);
                    setResult(1,intent);
                    finish();
                }else {
                    Toast.makeText(context,getResources().getString(R.string.password_error), Toast.LENGTH_SHORT).show();

                }
            }
        });
    }
}
